package com.arpa.wms.mapper;

import com.arpa.wms.domain.dto.ExpenseDetailDTO;
import com.arpa.wms.domain.entity.ExpenseDetail;
import com.arpa.wms.domain.vo.ContractSchedulingVO;
import com.arpa.wms.domain.vo.ExpenseDetailVO;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import org.apache.ibatis.annotations.Param;

import java.math.BigDecimal;
import java.util.List;

/**
 * <p>
 * 仓库费用明细 Mapper 接口
 * </p>
 *
 * @author LEO
 * @since 2020-11-17
 */
public interface ExpenseDetailMapper extends BaseMapper<ExpenseDetail> {

    /**
     * 查询列表
     * @param expenseDetailDTO
     * @return
     */
    List<ExpenseDetailVO> queryList(ExpenseDetailDTO expenseDetailDTO);

    /**
     * 查询合计,包含总数
     * @param expenseDetailDTO
     * @return
     */
    ExpenseDetailVO queryListSum(ExpenseDetailDTO expenseDetailDTO);


    /**
     * 获取计费排期信息
     * @return
     */
    List<ContractSchedulingVO> findBillingScheduling();

    /**
     * 更新计费排期计费状态
     * @param codes
     */
    void updateBillingSchedulingStatus(@Param("codes") List<String> codes, @Param("groupCode") String groupCode);


    /**
     * 生成结算单时更新费用金额
     * @param code 费用明细标识
     * @param thisSettledMoney  本次结算金额
     * @param byCode 操作人code
     * @param name 操作人姓名
     */
    void updateSettlementMoney(@Param("code") String code,@Param("thisSettledMoney") BigDecimal thisSettledMoney,@Param("byCode") String byCode,@Param("name") String name);
    /**
     * 删除结算单后还原收费信息
     * @param code 费用标识
     * @param restoreMoney 要还原的金额
     */
    void restoreSettlementStatus(@Param("code") String code, @Param("restoreMoney") BigDecimal restoreMoney);

    /**
     * 收款单审核通过后确认收费信息
     * @param code 费用标识
     * @param confirmMoney 确认金额
     */
    void confirmSettlementStatus(@Param("code") String code, @Param("confirmMoney") BigDecimal confirmMoney);

    /**
     * 按件计费数量查询
     * @param warehouseCode 仓库标识
     * @param shipmentCode 货主标识
     * @param goodsCode 商品标识
     * @param receiveLot 收货批次
     * @return 计费数量 {@link BigDecimal}
     */
    BigDecimal getBillingQuantityForPiece(@Param("warehouseCode") String warehouseCode,@Param("shipmentCode") String shipmentCode,@Param("goodsCode") String goodsCode, @Param("receiveLot") String receiveLot);


    /**
     * 按库位数计费数量查询
     * @param warehouseCode 仓库标识
     * @param shipmentCode 货主标识
     * @param goodsCode 商品标识
     * @param receiveLot 收货批次
     * @return 计费数量 {@link BigDecimal}
     */
    BigDecimal getBillingQuantityForLocation(String warehouseCode, String shipmentCode, String goodsCode, String receiveLot);
}
